package com.yishusmt.mobsmt.controller;

import com.yishusmt.mobsmt.dto.base.Result;
import com.yishusmt.mobsmt.dto.request.EditPasswordReq;
import com.yishusmt.mobsmt.dto.request.UserInfoReq;
import com.yishusmt.mobsmt.dto.request.UserLoginReq;
import com.yishusmt.mobsmt.dto.response.UserRes;
import com.yishusmt.mobsmt.service.UserManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户资料管理
 *
 * @author zhangyi
 * @date 2018/8/11 15:37
 */
@RestController
@RequestMapping("/userInfo")
@Api("用户信息管理")
public class UserManageController{

    @Resource
    private UserManageService userManageService;

    /**
     * 获取用户详细信息
     *
     * @param phone
     * @return
     */
    @GetMapping("/getUserInfo/{phone}")
    @ApiOperation(value = "获取用户信息",httpMethod = "GET")
    public Result getUserInfo(@PathVariable(value = "phone") String phone){
        System.out.println(userManageService.getUserInfo(phone));
        return userManageService.getUserInfo(phone);
    }

    /**
     * 编辑用户信息
     *
     * @param userRes
     * @return
     */
    @PostMapping("/editUserInfo")
    @ApiOperation(value = "编辑用户信息",httpMethod = "POST")
    public Result editUserInfo(@RequestBody UserInfoReq userRes){
        return userManageService.editUserInfo(userRes);
    }

    /**
     * 修改用户密码
     *
     * @param editPasswordReq
     * @return
     */
    @PostMapping("/editPassword")
    @ApiOperation(value = "修改用户密码",httpMethod = "POST")
    public Result editPassword(@RequestBody EditPasswordReq editPasswordReq){
        return userManageService.editPassword(editPasswordReq);
    }

    /**
     * 绑定用户（手机/邮箱）TODO
     *
     * @param phone
     * @param contact
     * @return
     */
    @PostMapping("/bing/{phone}/contact")
    @ApiOperation(value = "绑定用户（手机/邮箱）",httpMethod = "POST")
    public Result bing(@PathVariable(value = "phone") String phone,
                       @PathVariable(value = "contact") String contact){
        return null;
    }
}